package com.hopu.controller;


import com.alibaba.fastjson.JSON;
import com.hopu.bean.Menu;
import com.hopu.config.TreeBuild;
import com.hopu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class MenuController {
    @Autowired
    UserService userService;

    @RequestMapping("/menu")
    @ResponseBody
    public String menu()throws Exception{
        TreeBuild treeBuild=new TreeBuild(userService.menuquery());
        List<Menu> menus=treeBuild.buildTree();
        return JSON.toJSONString(menus);

    }
}
